//
// Created by Dell on 2020/3/26.
//
#include <iostream>
using namespace std;

long long horner(int *a, int n, int x){
    long int p = a[n];
    for (int j = 1; j <= n; j++)
        p = x * p + a[n - j];
    return p;
}

int main(){
    int a[] = {5, 16, 7,45,34,18};
    int length = sizeof(a) / sizeof(int);
    cout << horner(a, length, 5) << endl;
}